# -*- coding: utf-8 -*-
"""
Created on Wed May  9 13:52:59 2018

@author: 朱震东
"""
import os,shutil
import skimage
from PIL import Image  #对应pillow包
import scipy.misc
from matplotlib import pyplot as plt
import numpy as np
from pylab import *
import random

with open('result.txt') as file_object:
    contents = file_object.read()
contents = contents.split('\n')
"""
contents = contents.replace('\t',' ')
print(contents)
file_object = open('result2.txt', 'w')
file_object.write(contents)
file_object.close( )
"""
for i in range(len(contents)):
    if contents[i] == '':
        del contents[i]
    else:
        contents[i] = contents[i].split(' ')
print(contents)
print(len(contents))

def mycopyfile(srcfile,dstfile):
    if not os.path.isfile(srcfile):
        print("%s not exist!"%(srcfile))
    else:
        fpath,fname=os.path.split(dstfile)    #分离文件名和路径
        if not os.path.exists(fpath):
            os.makedirs(fpath)                #创建路径
        shutil.copyfile(srcfile,dstfile)      #复制文件
        print("copy %s -> %s"%( srcfile,dstfile))

srcpath = 'datasets/test/'
detpath = 'result/'
for i in range(len(contents)):
    mycopyfile(srcpath+contents[i][0],detpath+contents[i][1]+'/'+contents[i][0])
        